package cn.mw.util;

import lombok.Data;

/**
 * 
 * @ClassName: AjaxResult
 * @Description: TODO(封装异步操作增删改之后的返回结果)
 * @company 源码时代
 * @author Tom
 * @version V1.0.0
 * @date 2021-04-09 15:29:42
 */
@Data
public class AjaxResult {
	
	private Boolean success = true;
	private String msg = "操作成功";
	private Object resultObj;

	public static AjaxResult success(Object o ){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setSuccess(true);
		ajaxResult.setMsg("操作成功");
		ajaxResult.setResultObj(o);
		return ajaxResult;
	}

	public static AjaxResult fail(String msg ){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setSuccess(false);
		ajaxResult.setMsg(msg);
		return ajaxResult;
	}

	public AjaxResult(){}

	//链式语法改造
	public static AjaxResult me(){
		return new AjaxResult();
	}
	public Boolean getSuccess() {
		return success;
	}
	//链式语法改造
	public AjaxResult setSuccess(Boolean success) {
		this.success = success;
		return this;
	}
	public String getMsg() {
		return msg;
	}
	//链式语法改造
	public AjaxResult setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public Object getResultObj() {
		return resultObj;
	}

	public AjaxResult setResultObj(Object resultObj) {
		this.resultObj = resultObj;
		return this;
	}

	@Override
	public String toString() {
		return "AjaxResult [success=" + success + ", msg=" + msg + "]";
	}

	/*public static void main(String[] args) {
		System.out.println(AjaxResult.me().setSuccess(false).setMsg("操作失败").setResultObj("呵呵"));
	}
	*/
}
